#include <stdlib.h>
#include <stdio.h>
#include "list.h"

int main (void) {

    struct queue_thread *qt = new_queue_thread ();
    print_queue(qt);
    
    thread_t t01 = malloc (sizeof (struct thread));
    t01->id = 31;
    t01->priority = 1;
    add_thread (qt, t01);
    print_queue(qt);
    
    thread_t t02 = malloc (sizeof (struct thread));
    t02->id = 64;
    t02->priority = 0;
    add_thread (qt, t02);
    print_queue(qt);

    qt = new_queue_thread ();
    print_queue(qt);
    
    thread_t t1 = malloc (sizeof (struct thread));
    t1->id = 31;
    t1->priority = 1;
    add_thread (qt, t1);
    print_queue(qt);
    
    thread_t t2 = malloc (sizeof (struct thread));
    t2->id = 64;
    t2->priority = 1;
    add_thread (qt, t2);
    print_queue(qt);

    thread_t t3 = malloc (sizeof (struct thread));
    t3->id = 51;
    t3->priority = 4;
    add_thread (qt, t3);
    print_queue(qt);

    thread_t t4 = malloc (sizeof (struct thread));
    t4->id = 99;
    t4->priority = 3;
    add_thread (qt, t4);
    print_queue(qt);
      
    thread_t t5 = malloc (sizeof (struct thread));
    t5->id = 101;
    t5->priority = 3;
    add_thread (qt, t5);
    print_queue(qt);
          
    thread_t t6 = malloc (sizeof (struct thread));
    t6->id = 0;
    t6->priority = 0;
    add_thread (qt, t6);
    print_queue(qt);

    thread_t t7 = malloc (sizeof (struct thread));
    t7->id = 2;
    t7->priority = 2;
    add_thread (qt, t7);
    print_queue(qt);
 
    thread_t first;
    
    first = get_first_thread (qt);
    printf("%d\t", first->id);
    print_queue(qt);

    first = extract_first_thread (qt);
    printf("%d\t", first->id);
    print_queue(qt);
    
    first = extract_first_thread (qt);
    printf("%d\t", first->id);
    print_queue(qt);
          
    first = extract_first_thread (qt);
    printf("%d\t", first->id);
    print_queue(qt);
          
    first = extract_first_thread (qt);
    printf("%d\t", first->id);
    print_queue(qt);
          
    first = extract_first_thread (qt);
    printf("%d\t", first->id);
    print_queue(qt);
          
    first = extract_first_thread (qt);
    printf("%d\t", first->id);
    print_queue(qt);
          
    first = extract_first_thread (qt);
    printf("%d\t", first->id);
    print_queue(qt);
          
    first = extract_first_thread (qt);
    if (first == NULL) printf("empty\t");
    print_queue(qt);
    
    add_thread (qt, t7);
    print_queue(qt);
 
    add_thread (qt, t6);
    print_queue(qt);
 
    add_thread (qt, t5);
    print_queue(qt);
    
    add_thread (qt, t5);
    print_queue(qt);
     
    return EXIT_SUCCESS;
}
